#pragma once
/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * DNS Well-Known-Service Record Structure
 *      Represents a DNS well-known service (WSK) record.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
#include "stdafx.h"
using namespace System;
using namespace System::Net;

namespace Adaptive
{
	namespace Network
	{
		namespace Dns
		{
			/// <summary>
			/// Represents a DNS well-known service (WSK) record.
			/// </summary>
			public value struct DnsWellKnownServiceRecord
			{
			internal:
				/// <summary>
				/// Initializes a new instance of the class from the unmanaged record.
				/// </summary>
				/// <param name="record"> A pointer to a DNS_RECORD structure whose contents are to be copied.</param>
				DnsWellKnownServiceRecord(DNS_RECORD* record)
				{
					if (record == NULL)
					{
						IP = nullptr;
						Protocol = 0;
						Bitmask = nullptr;
					}
					else
					{
						IP = gcnew IPAddress( (DWORD)record->Data.WKS.IpAddress );
						Protocol = record->Data.WKS.chProtocol;
						Bitmask = gcnew array<Byte>(1);
						Bitmask[0] = record->Data.WKS.BitMask[0];
					}
				}
			private:
				/// <summary>
				/// Static constructor.
				/// </summary>
				static DnsWellKnownServiceRecord()
				{
				}
			public:
				/// <summary>
				/// IP Address.
				/// </summary>
				/// <value>
				/// An IPAddress instance or null.
				/// </value>
				IPAddress^		IP;
				/// <summary>
				/// IP protocol for this record. Valid values are UDP or TCP.
				/// </summary>
				/// <value>
				/// Protocol indicator value.
				/// </value>
				Byte			Protocol;
				/// <summary>
				/// Mask representing well known service being represented in the resource record (RR).
				/// </summary>
				/// <value>
				/// A byte array containing the bitmask.
				/// </value>
				array<Byte>^	Bitmask;
			};
		}
	}
}